package com.zrrd.yt.weball.controller;

import com.zrrd.yt.model.order.OrderInfo;
import com.zrrd.yt.order.client.OrderFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * @author HongyueYang
 */
@Controller
public class PaymentController {
    @Autowired
    private OrderFeignClient orderFeignClient;

    @GetMapping("/pay.html")
    public String pay(HttpServletRequest request){
        //获取地址中传递过来的订单id
        String orderId = request.getParameter("orderId");
        //调用远程服务feign，根据订单id查询订单信息
        OrderInfo orderInfo = orderFeignClient.getOrderInfo(Long.parseLong(orderId));
        //存入请求
        request.setAttribute("orderInfo",orderInfo);
        //跳转到支付下单页面
        return "payment/pay";
    }
}
